Welcome to buy time in three hours.
If we divide the data points into training and testing data points randomly, there is a chance that
the division is being accidentally such that the evaluation data becomes too easy or too hard for the
model to be evaluated.
Also, the training data might be such that the model is not a real challenge statistically when being
evaluated in this case to prevent any statistical bias for a particular rate of testing to training
such as 20 percent and rates of testing, the training is abbreviated as RTT.
The testing training random division is being repeated a number of times, say twenty five times.
In this example, each time a different set of testing, training, data points is being generated.
This is called repeated random sampling or is in machine learning.
Literature for each hour is the model or our student is being trained and tested by the corresponding
training, testing, data points and accuracy is being reported for each hour.
Asked for a classification problem, one may consider the average accuracy measurement of 25 or is as
the accuracy of the model for a minority of 20 percent.
Demorris, the number of error is the less is this statistical bias becomes not that we usually cannot
eliminate this statistical bias, but we can reduce it by such repetitions.
In addition, it would provide a fairly unbiased evaluation if the model is not just being evaluated
for a particular RTT of, say, 20 percent, but for different parties as well.
For example, we can have five Arty's of 10 percent, 20 percent, 30 percent, 40 percent and 50 percent.
And for each RTT we can have twenty five repetitions or Ursus.
We can then create a table such as this table and report the accuracy or masc of the model for each
RTT and each other is OK.
Let's practice what we learn in this lecture.
The first thing to imports unnecessary libraries and excel.
As usual, we import non-pay and pundits, but here we have two necessary packages from the famous Machine
Learning Library.
Schertler And we are going to import a method of the Class of České Learn, which is called model selection.
And we import it as a mess.
And the other one is for data processing, which is called preprocessing and we import it has PJI this,
Randi.
So to have all of these libraries in our workspace, OK, here we are practicing how to divide our training
and testing or train to split hairs up on his cell.
So in this example, I'm going to load our California housing train data to CSFI data using Ponder's.
And then we're going to assume that this is not just a training data, but the whole data for the time
being.
We just make that assumption.
Then I can actually show you how to divide this data into training and testing.
So forget this train term here and assume that this is just the whole data, the whole repository.
So in that data, the input data or whatever you see in the first columns except the last column and
in the last column, which we can call it with the index minus one, we have our output data, which
is the housing prices in California.
So let's run this cell and have data in and out in our repository.
Then here we can actually have a split function so we can use these M.
S that train to split function.
And here we put our data in and data output.
Here we define our RTT, which is called test size here, and it is twenty percent.
So it goes with point to add some random state for randomly division and we set it to be forty two as
the integer of the seat value and here as the outputs we have four outputs, the data input corresponding
to training data input corresponding to testing data output of training and data output of testing.
So if I run this I can actually print everything here in an organized manner and then you're going to
see the top five rows of each of these four outputs here.
So we have our training inputs here, which includes the location of the house to the number of bedrooms,
households.
Everything is being actually skipped here to show things to you in a similar way.
So it's a five rows and eight columns, the top five rows and the corresponding outputs of each data
point that you see here are here as your training outputs data.
And here is for your inputs after testing.
As you see, we have five rows and eight columns.
Of this testing input, data points and the corresponding outputs here in this cell, we can see how
we can have multiple audits and multiple addresses.
We first define a list of all the activities we want to consider, for example, 10 percent, 20 percent,
30 percent, 40 percent and 50 percent.
And I put them here as point one two point five in a list back to back then, I'm going to define a
range of activities which we can use the range function and the length of our list.
So this is basically zero one, two, three and four and an arrest range.
And we assume that in this example we have 25 repetitions.
So we have the range of twenty five as our range.
Then here I'm going to actually define an empty number by Arry and an empty number I carry has two dimensions,
which the first dimension goes with the length of RTG range, which is five and the length of our IS
range which is twenty five.
And here I can define the type of that empty file which I wanted to be dictionary and I'm going to see
that way.
I'm actually programming it this way shortly here I define to follow.
The first full loop is for minorities and the second one is for my RSS and the first one go through
my RTT range and the second one goes through my are a stretch.
And once we are within the second loop, we divide our data in and data out based on the test size that
coming through these RTT lists and these counter RTT.
So RTT, Ålesund, RTT for the first time is like RTT of 10 percent and we have a random state here.
So once we divide our data in and out based on that RTT into testing and training inputs and outputs,
we can save them all in a dictionary.
So define a data dictionary here, which has four keys, data in training data, our training data in
testing and data, our testing and notat for abbreviation.
I use data in as the inputs and data out, as the outputs I use and underline and TR is for training
and the T is for testing just to make things easier when we write a code.
This is my start.
You can have your honesty.
And then in that empty file that I define here as the data, which the type is the dictionary, I'm
going to actually save this dictionary within it.
So once I run all this for loop, I'm going to have twenty five reputations of five RTT all being saved
on different elements of this data file.
So for example, after only slope, I can train the dictionary corresponding to RTT number two and number
six and that goes like RTT two and six.
That's from the cell.
And here is the dictionary corresponding to RTT number two.
Unarrest number six.
As you see here, we have our input data corresponding to training output, data of training, input,
data testing and output data testing.
In this lecture, you'll learn about some machine learning, data, repository jargons, training and
testing steps in machine learning and repeat random sampling in machine learning.
In the next lecture, we will learn about data processing and calibration in machine learning.
Thank you for your attention.
See you all in the next lecture.